<template>
  <div class="app-container">
    <el-page-header content="编辑" @back="onCancel" />
    <el-divider />
    <el-form :model="form" label-width="120px" style="width:30vw">
      <el-form-item label="系统名称">
        <el-input v-model="form.systemName" />
      </el-form-item>
      <el-form-item label="操作类型">
        <el-input v-model="form.operation" />
      </el-form-item>
      <el-form-item label="操作人">
        <el-input v-model="form.userName" />
      </el-form-item>
      <el-form-item label="操作描述">
        <el-input v-model="form.description" type="textarea" />
      </el-form-item>
      <el-form-item>
        <el-popconfirm title="确认提交吗？" @confirm="onSubmit(form)">
          <el-button slot="reference" type="primary">提交</el-button>
        </el-popconfirm>
        <el-button @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { successMsg } from '@/utils/comm'
import { getComm, updateComm } from '@/api/comm'

export default {
  data() {
    return {
      module: 'user',
      form: {
      }
    }
  },
  created() {
    const id = this.$route.params.id
    this.getData(id)
  },
  methods: {
    getData(id) {
      getComm(this.module, id).then(response => {
        this.form = response.data
      })
    },
    onSubmit(form) {
      updateComm(this.module, form).then(response => {
        successMsg()
      })
    },
    onCancel() {
      this.$router.push('/user/index')
    }
  }
}
</script>

<style scoped>
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}

.avatar {
  width: 178px;
  height: 178px;
  display: block;
}

</style>

